<template>
	<!-- <scroll-view class="wanlshop-page-container" :scroll-y="true"   @scrolltoupper="handleUpper" @scrolltolower="handleLower"> -->
	<view>
		<!-- 商家数据 -->
		<view v-if="shopData" class="wanlshop-shop-container__shop padding-sm radius-bock"
			@click="$wanlshop.to(`info?id=${shopData.id}`)">
			<view class="info">
				<view class="name text-cut text-bold">
					<block v-if="shopData.isself === 1">
						<view class="cu-tag radius sm bg-red"><!-- 自营 -->{{$t('shop-page.tag.zy')}}</view>
					</block>
					<block v-else>
						<view class="cu-tag radius sm wanl-bg-pink" v-if="shopData.state == 0">
							<!-- 个人 -->
							{{$t('shop-page.tag.gr')}}
						</view>
						<view class="cu-tag radius sm wanl-bg-blue" v-else-if="shopData.state == 1">
							<!-- 企业 -->
							{{$t('shop-page.tag.qy')}}
						</view>
						<view class="cu-tag radius sm wanl-bg-orange" v-else-if="shopData.state == 2">
							<!-- 旗舰 -->
							{{$t('shop-page.tag.qj')}}
						</view>
					</block>
					<text class="margin-left-xs">{{ shopData.shopname }}</text>
				</view>
				<view class="exponent text-min wanl-gray-dark">
					<view>
						<text class="margin-right-xs"><!-- 店铺粉丝 -->{{$t('shop-page.tips.fans')}}</text>
						{{ shopData.find_user.fans }}
					</view>
				</view>
			</view>
		</view>
		<!-- 自定义首页 -->
		<view v-if="pageModules" :style="{
          backgroundRepeat: pageModules.page
            ? pageModules.page.style.pageBackgroundRepeat
            : 'repeat',
          backgroundPosition: `0 ${headTop}px`,
		    paddingTop:$u.addUnit( $u.sys().statusBarHeight,'px')
        }" style="background-size: 100% auto">
			<view v-for="(item, index) in arr" :key="index">
				<wanl-page-banner v-if="item.type == 'banner'" :pageData="item" />
				<xzw-notice :list="list" :showMore="false" :showIcon="true" v-if="index == 0" />

				<wanl-page-yuanbao v-if="item.type == 'banner'" :pageData="item" />
				<view class="shequbox" v-if="index == 0" @click="onLink('/pages/community?index=1','tabbar','auth')">
					<view class="name"><!-- 我的社区 -->{{$t('shop-page.tips.community')}}</view>
					<!-- <view class="smallname">添加文案 添加文案</view> -->
				</view>
				<wanl-page-goods v-if="item.type == 'goods'&&item.data.length>0" :pageData="item" />
				<wanl-page-empty v-if="item.type == 'empty'" :pageData="item" />
				<wanl-page-division v-if="item.type == 'division'" :pageData="item" />
			</view>
			<!-- <uni-load-more status="noMore" :content-text="contentText" /> -->
			<view v-if="shopData" class="safeAreaBottom"></view>
		</view>
		<wanl-empty v-else src="find_default3x" :text="$t('shop-page.empty.text')" />
		<!-- 正在配置首页中... -->
	</view>
	<!-- </scroll-view> -->
</template>

<script>
	export default {
		name: "WanlShopPage",
		props: {
			windowHeight: {
				type: Number,
				default: 0,
			},
			headHeight: {
				type: Number,
				default: 0,
			},
			headTop: {
				type: Number,
				default: 0,
			},
			shopData: {
				type: Object,
				default () {},
			},
			pageModules: {
				type: Object,
				default () {},
			},
			adData: {
				type: Object,
				default () {},
			},
		},
		data() {
			return {
				likesLower: 0,
				contentText: {
					contentdown: "下拉加载更多",
					contentrefresh: "加载中",
					contentnomore: "我是有底线的",
				},
				list: [],
				arr: [{
						name: "轮播组件",
						type: "banner",
						style: {
							color: "#000000",
						},
						params: {
							interval: "2800",
							height: "230rpx",
							banstyle: "1",
						},
						data: [],
					},
					{
						name: "商品组件",
						type: "goods",
						style: {
							"background-color": "#f5f5f5",
						},
						params: {
							colthree: "2",
							colmargin: "25",
						},
						data: [
						],
					},
				],
			};
		},
		created() {
			this.getNoticeList()
			this.getBannerList()
			this.getGoodsList()
		},
		methods: {
			onLink(url, type, auth) {
				if (url == '') {
					return uni.showToast({
						icon: 'none',
						title: this.$t('shop-page.toast.notopen') //'功能开发中,敬请期待'
					})
				}
				let user = uni.getStorageSync("wanlshop:user")
				if (auth == 'auth' && !user) {
					return uni.showToast({
						icon: 'none',
						title: this.$t('shop-page.toast.notlogin')//'未登录,请先登录'
					})
				}
				if (type == 'tabbar') {
					uni.reLaunch({
						url:url
					})
				} else {
					this.$wanlshop.on(url);
				}
			},
			getNoticeList() {
				uni.request({
					url: "/index/noticeList",
					method: "POST",
					data: {},
					complete: (res) => {
						if (res.res.code == 1) {
							this.list = res.res.data
						}
					},
				});
			},
			getGoodsList() {
				uni.request({
					url: "/Wanlshop/Page/honeGoods",
					method: "POST",
					data: {},
					complete: (res) => {
						if (res.res.code == 1) {
							this.arr[1].data = res.res.data
						}
					},
				});
			},
			getBannerList() {
				uni.request({
					url: "/index/wapBanner",
					method: "POST",
					data: {},
					complete: (res) => {
						if (res.res.code == 1) {
							this.arr[0].data = res.res.data
						}
					},
				});
			},
			handleFollow() {
				this.$emit("handleHandleFollow");
			},
			// 上拉刷新
			handleUpper(e) {},
			// 下拉加载
			handleLower(e) {
				this.likesLower = e.timeStamp;
			},
		},
	};
</script>

<style lang="scss">
	.shequbox {
		height: 182rpx;
		background: url("../../static/images/index/image@2x.png") no-repeat;
		background-size: 100% 100%;
		margin: 0 32rpx;
		padding-left: 30rpx;
		// padding-top: 40rpx;
		display: flex;
		align-items: center;
		.name {
			font-size: 36rpx;
			color: #ffffff;
		}

		.smallname {
			font-size: 24rpx;
			color: #ffffff;
			margin-top: 10rpx;
		}
	}

	.wanlshop-shop-container {
		&__shop {
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: rgba(0, 0, 0, 0.05);
			margin: 0 16rpx 16rpx 16rpx;

			.info {
				width: calc(100% - 260rpx);
				display: flex;
				align-content: space-between;
				flex-wrap: wrap;
				height: 85rpx;

				.name {
					width: 90%;
				}

				.exponent {
					display: flex;
				}
			}

			.menu {
				text-align: right;
				width: 260rpx;
			}
		}
	}
</style>